//
//  FKDownloadingTableViewDataSourceImpl.m
//  FK
//
//  Created by handy wang on 6/8/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>

#import "FKDownloadingTableViewDataSourceImpl.h"
#import "FKDownloadManager.h"
#import "FKDownloadTask.h"
#import "FKDownloadingTableViewCell.h"

@implementation FKDownloadingTableViewDataSourceImpl

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    int count = [[FKDownloadManager sharedInstance] downloadingTasks].count;
    NSLog(@"INFO: Downloading tasks count is %d", count);
    return count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *_reuseIdentifier = @"FKDownloadingTableViewCell";
    FKDownloadingTableViewCell *_cell = [tableView dequeueReusableCellWithIdentifier:_reuseIdentifier];
    if (!_cell) {
        _cell = [[FKDownloadingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:_reuseIdentifier];
    }
    [_cell setDownloadTask:(FKDownloadTask *)[[FKDownloadManager sharedInstance].downloadingTasks objectAtIndex:indexPath.row]];
    return _cell;
}

@end